<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap.min.css">
</head>
<style>
	label {
		text-align: right;
	}

</style>
<body>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
	<form class="form-horizontal" onsubmit="return false" id="form">
		<fieldset>
			<input type="hidden" id="id" name="id">
			<div class='form-group'>
				<label class='col-md-2'>用户id</label>
				<div class='col-md-10'>
					<span id="userid" style="padding-top: 17px; "></span>
				</div>
			</div>

			<div class='form-group'>
				<label class='col-md-2'>昵称</label>
				<div class='col-md-10'>
					<span id="nickname" style="padding-top: 17px; "></span>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2'>银行</label>
				<div class='col-md-10'>
					<span id="bank" style="padding-top: 17px; "></span>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2'>银行卡号</label>
				<div class='col-md-10'>
					<span id="bankcardnumber" style="padding-top: 17px; "></span>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2'>真实姓名</label>
				<div class='col-md-10'>
					<span id="realname" style="padding-top: 17px; "></span>
				</div>
			</div>


			<div class='form-group'>
				<label class='col-md-2 '>总金额</label>
				<div class='col-md-10'>
					<span id="nowmoney"></span>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 '>提现金额</label>
				<div class='col-md-10'>
					<span id="expenditure"></span>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 '>扣点比例</label>
				<div class='col-md-10'>
					<span id="points"></span>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 '>扣点后金额</label>
				<div class='col-md-10'>
					<span id="pointsmoney"></span>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 '>用户剩余金额</label>
				<div class='col-md-10'>
					<span id="surplus"></span>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 '>状态</label>
				<div class='col-md-10'>
					<span id="state"></span>
				</div>
			</div>


			<div class="form-actions">
				<div class="row" align="center">
					<div class="col-md-12">

						<button class="btn btn-primary" type="submit" onclick="finish()">
							<i class="fa fa-save"></i> 完成
						</button>&nbsp;&nbsp;&nbsp;

						<button class="btn btn-primary" type="submit" onclick="refuse()">
							<i class="fa fa-save"></i> 拒绝
						</button>&nbsp;&nbsp;&nbsp;

						<button class="btn btn-primary" onclick="location.href='mffCashwithdrawalapplicationList.html'">返回</button>
					</div>
				</div>
			</div>

		</fieldset>
	</form>
</div>
<script type="text/javascript" src="../../js/libs/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../js/jq.js"></script>
<script type="text/javascript" src="../../js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script type="text/javascript" src="../../layui/layui.js"></script>
<script type="text/javascript" src="../../js/my/permission.js"></script>
	<script type="text/javascript">
		layui.use(['layer','laydate'], function(){
		    var layer = layui.layer;
		});
		
		initData();
		
		function initData(){
			var id = getUrlParam("id");
			if(id != ""){
				$.ajax({
					type : 'get',
					url : '/mffCashwithdrawalapplications/'+id,
					async : false,
					success : function(data) {
						$('#id').val(data.id);
						$('#userid').html(data.userid);
						$('#nowmoney').html(data.nowmoney);
						$('#expenditure').html(data.expenditure);
						$('#points').html(data.points);
						$('#pointsmoney').html(data.pointsmoney);
						$('#surplus').html(data.surplus);
						if (data.state == '1'){
                            $('#state').html("提现成功");
						} else if (data.state == '2'){
                            $('#state').html("提现失败");
                        } else if (data.state == '3'){
                            $('#state').html("申请提现");
                        } else if (data.state == '4'){
                            $('#state').html("用户取消提现");
                        }
                        $('#nickname').html(data.nickname);
                        $('#bank').html(data.bank);
                        $('#bankcardnumber').html(data.bankcardnumber);
                        $('#realname').html(data.realname);



					}
				});
			}
		}

		function update() {
			$('#form').bootstrapValidator();
			var bootstrapValidator = $("#form").data('bootstrapValidator');
			bootstrapValidator.validate();
		    if(!bootstrapValidator.isValid()){
			   return;
		    }
		    
		    var formdata = $("#form").serializeObject();

			$.ajax({
				type : 'put',
				url : '/mffCashwithdrawalapplications',
				contentType: "application/json; charset=utf-8",  
				data : JSON.stringify(formdata),
				success : function(data) {
					layer.msg("修改成功", {shift: -1, time: 1000}, function(){
                        location.href = "mffCashwithdrawalapplicationList.html";
                    });
				}
			});
		}



        function finish(){
		    var id = $("#id").val();

            layer.confirm('确定同意该用户提现吗？请先给用户付完钱在点击完成！', {
                btn : [ '确定', '取消' ]
            }, function() {
                $.ajax({
                    type : 'post',
                    url : '/mffCashwithdrawalapplications/finish/'+id,
                    success : function(data) {
                        console.log(data);
                        if (data.errCode == '200'){
                            layer.msg("提现成功", {shift: -1, time: 1000}, function(){
                                location.href = "mffCashwithdrawalapplicationList.html";
                            });
						} else {
                            layer.msg(data.message);
						}

                    }
                });

                layer.close(1);
            });
        }


        function refuse(){
            var id = $("#id").val();
            layer.confirm('确定拒绝该用户的提现吗？', {
                btn : [ '确定', '取消' ]
            }, function() {
                $.ajax({
                    type : 'post',
                    url : '/mffCashwithdrawalapplications/refuse/'+id,
                    success : function(data) {
                        if (data.errCode == '200'){
                            layer.msg("已拒绝", {shift: -1, time: 1000}, function(){
                                location.href = "mffCashwithdrawalapplicationList.html";
                            });
                        } else {
                            layer.msg(data.message);
                        }
                    }
                });

                layer.close(1);
            });
        }

	</script>
</body>
</html>
